﻿#ifndef MAINWIDGET_H
#define MAINWIDGET_H

#include <QWidget>
#include <QGroupBox>
#include <QNetworkAccessManager>
#include <QNetworkRequest>
#include <QNetworkReply>
#include <QVector>
#include <QStandardItemModel>
#include "login.h"
#include "chatsocket.h"
#include "friendbutton.h"
#include "music.h"
#include <QVBoxLayout>
#include "addfriend.h"
namespace Ui {
class MainWidget;
}

class MainWidget : public QWidget
{
    Q_OBJECT

public:
    explicit MainWidget(QWidget *parent = 0);
    ~MainWidget();
protected:
     void closeEvent(QCloseEvent *event);
private:
    Ui::MainWidget *ui;
    Login* login;   //登录界面
    ChatSocket *socket;
    AddFriend *friend_add;
    int id;
    QString uname;
    QVBoxLayout *layout_friend;
    QVBoxLayout *layout_group;
    QNetworkAccessManager* m_networkManager;
    QNetworkAccessManager* m_get_host;
    Music *music_mange;
    QVector <FriendButton* > friend_list;
    QStandardItemModel *standItemModel;
    QString timeall;
public slots:
    void slotLogonSuccess(int id,QString username,QString icon);
    void slotReplyFinished(QNetworkReply *);
    void slotFriendList(QJsonObject root);
    void slotChatDateDeal(QJsonObject root);
    void slotRefreshMusicList(QVector<SONG> music_list);    //更新音乐显示列表
    void updateDuration(qint64 duration);//更新播放歌曲的时间
    void updatePosition(qint64 position);//接收歌曲位置改变，那么滑块的位置也要变
private slots:
    void on_pushButton_3_clicked();
    void on_volume_valueChanged(int value);
    void on_horizontalSlider_sliderMoved(int position);
    void on_pushButton_clicked();
};

#endif // MAINWIDGET_H
